<% content_for :css do %>
  <%= stylesheet_link_tag 'moneys_show' %>
<% end %>
<% content_for :javascript do %>
<script type="text/javascript" charset="utf-8">
  function drawn_moneys(html) {
    $('get_moneys').update(html);
    $('get_moneys').show();    
    Effect.Squish('get_moneys', {duration:5});
  }
  
  function show_items(items_id) {
    $$('div.items').each(function(item) {
      item.hide();
    });
    $(items_id).show();
    $$('a.nav_bar_item').each(function(item) {
      item.className = 'nav_bar_item'
    });
    $('go_to_' + items_id).className = 'nav_bar_item h';
  }
  
  function show_title(title_id) {
    $$('div#my_moneys div#right div.body div#earn_money div.body').each(function(item) {
      item.hide();
    });
    $(title_id).show();  
    $$('div#my_moneys div#right div.body div#earn_money div.titles a.title').each(function(a) {
      a.className = 'title'
    });
    $('go_to_' + title_id).className = 'title h';
  }
  
  function reflash_feeds() {
    reload_earnings();
    <%= remote_function :update => 'earned',
          :url => how_to_earn_moneys_url,
          :method => :get %>
    <%= remote_function :update => 'money_feeds',
          :url => feeds_moneys_url,
          :method => :get %>
  }
  
  function reload_earnings() {
    <%= remote_function :update => 'earning',
          :url => how_to_earn_moneys_url,
          :method => :get %>
  }
  
  function next_feed(feeds_id) {
    var current = null;
    var next = null;
    $$('dl#' + feeds_id + ' dd.feed').each(function (feed) {
      if(next == null) {
        if(current != null) {
          next = feed;
        } else {
          if(feed.style.display == '') {
            current = feed;
            current.hide();
          }  
        }
      }
    });
    if(current != null && next == null) {
      next = $$('dl#' + feeds_id + ' dd.feed')[0];
    }
    Effect.Appear(next);
  }
</script>
<% end %>  
<%= render :file => 'users/_level2_nav_bar.html', :locals => { :item => :money} %>
<div id="get_moneys" style='display:none'></div>
<div id="my_moneys">
  <div id='left'>
    <div class="title">
      <div>
        我的麦粒
      </div>
    </div>
    <div id="user">
      <div class='logo'>
        <%= user_logo_image_tag current_user,:width => 40 %>
      </div>
      <div class='info'>
        <div class='name'>
          <%= link_to current_user.nick_name, edit_user_url(current_user), :target => :_blank %>
        </div>
        <div class="money">
          <span id='my_left_money'><%= current_user.money %></span><%= image_tag 'base/money_32.png', :size => '18x18' %>
        </div>
      </div>      
      <div id='draw_money' class='moneys'>  
        <%= render 'draw_money_link_in_show.html' %>
      </div>
      <div id="items">
        <div class='item'>
          <%= link_to_remote '赚取麦粒',
                :update => 'earning',
                :url => how_to_earn_moneys_url,
                :method => :get,
                :loading => "show_items('earn_money');show_title('earning');#{normal_loading('earning', :height => 300)}",
                :complete => 'reflash_feeds()',
                :html => {
                  :id => 'go_to_earn_money',
                  :class => 'h nav_bar_item'
                } %>
        </div>
        <div class='item'>
          <%= link_to_remote '资产清单',
                :update => 'money_feeds',
                :url => feeds_moneys_url,
                :method => :get, 
                :loading => "show_items('money_feeds');#{normal_loading('money_feeds', :height => 300)}",
                :html => {
                  :id => :go_to_money_feeds, 
                  :class => 'nav_bar_item'
                } %>
        </div>
      </div>
    </div>
  </div>
  <div id='right'>
    <div class="title">
      
    </div>
    <div class='body'>
      <div class="my_money_title">
        我的麦粒：<span id='my_right_money'><%= current_user.money %></span>
      </div>
      <div>
        <div id="earn_money" class='items'>
          <div class="titles">
            <%= link_to_remote '如何赚取',
                  :update => 'earning',
                  :url => how_to_earn_moneys_url,
                  :method => :get,
                  :loading => "show_title('earning');#{normal_loading('earning', :height => 300)}",
                  :html => {
                    :id => "go_to_earning", 
                    :class => 'title h'
                  } %>
            <%= link_to_remote '我赚到的',
                  :update => 'earned',
                  :url => earned_moneys_url,
                  :method => :get,
                  :loading => "show_title('earned');#{normal_loading('earned', :height => 300)}",
                  :html => {
                    :id => "go_to_earned", 
                    :class => 'title'
                  } %>
          </div>
          <div>
            <div id='earning' class="body" >
              <%= render :file => 'moneys/how_to_earn.js.erb' %>
            </div>
          </div>
          <div>
            <div id="earned" class="body" style='display:none'>      
            </div>
          </div>
        </div>
      </div>
      <div>
        <div id="money_feeds" class='items'  style='display:none;'>
        </div>
      </div>
    </div>
  </div>
</div>